package basic.immutable;

import java.util.Objects;

/**
 * @author Cheng Jun
 * @version 1.0
 * Description:
 * @date 2019/10/17 13:31
 */
public class ImmutableTest {

    public static void main(String[] args) {
        String name = "cauchy6317";
        String name1 = new String(name);
        System.out.println(name.hashCode());
        System.out.println(name1.hashCode());
        System.out.println(name == name1);
        System.out.println(Objects.equals(name, name1));
        System.out.println(name.equals(name1));

        final Student student = new Student();
        Student student1 = new Student();
        System.out.println(student.equals(student1));
        System.out.println(student.hashCode());
        System.out.println(student1.hashCode());
        student.setAge(18L);

        Student jack = new Student();
        jack.setName("jack————");
        String jackName = jack.getName();
        System.out.println(jackName);
        jack.setName("jack");
        System.out.println(jackName);

        // try {
        //     Field valueField = name.getClass().getDeclaredField("value");
        //     valueField.setAccessible(true);
        //     char[] value = (char[])valueField.get(name);
        //     value[0] = 'C';
        // }catch (Exception ex){
        //     ex.printStackTrace();
        // }
        // System.out.println(name);
        // System.out.println(name1);
        // System.out.println(name.hashCode());
        // System.out.println(name1.hashCode());
        // String name2 = "Cauchy6317";
        // System.out.println(name2.hashCode());
        //
        // LocalDate now = LocalDate.now();
        // System.out.println(now);
        // LocalDate now1 = now.plusDays(1);
        // System.out.println(now1);
        //

        Integer age = 1;
        System.out.println(age);
        changeAge(age);
        System.out.println(age);
        String cauchy = "cauchy";
        System.out.println(cauchy);
        changeName(cauchy);
        System.out.println(cauchy);


    }

    static void changeAge(int age) {

        age += 1;
        System.out.println(age);
    }

    static void changeName(String cauchy) {
        cauchy = cauchy + "dddd";
        System.out.println(cauchy);
    }
}
